<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('sys_meet_manage列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>地点：</label>
                                <input type="text" name="localName"/>
                            </li>
                            <li>
                                <input name="deptId" type="hidden" id="treeId"/>
                                <label>部门：</label>
<!--                                <input type="text" name="deptId"/>-->
                                <input name="deptName" onclick="selectDeptTree()" id="treeName" placeholder="归属部门" type="text" class="form-control">
                            </li>
                            <li>
                                <label>会议名称：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:manage:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:manage:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:manage:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:manage:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:manage:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:manage:remove')}]];
        var prefix = ctx + "system/manage";
        var meetFlag = [[${@permission.hasPermi('system:manage:meet')}]]
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "sys_meet_manage",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '会议编号'
                },
                {
                    field: 'localName',
                    title: '会议室'
                },
                {
                    field: 'deptName',
                    title: '部门'
                },
                {
                    field: 'name',
                    title: '会议名称'
                },
                {
                    field: 'createName',
                    title: '创建人'
                },
                {
                    field: 'createTime',
                    title: '创建时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        if(row.meeting === 1){
                            actions.push('<a class="btn btn-success btn-xs begin" href="javascript:void(0)" onclick="openMeet(\'' + row.id + '\')"><i class="fa fa-edit"></i>开始会议</a> ');
                            actions.push('<a class="btn btn-danger btn-xs apply" href="javascript:void(0)" disabled="true"><i class="fa fa-edit"></i>结束会议</a> ');
                            actions.push('<a class="btn btn-warning btn-xs apply" href="javascript:void(0)" disabled="true"><i class="fa fa-edit"></i>会议纪要</a> ');
                        }else if(row.meeting === 2){
                            actions.push('<a class="btn btn-success btn-xs apply" href="javascript:void(0)" disabled="true"><i class="fa fa-edit"></i>开始会议</a> ');
                            actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="endMeet(\'' + row.id + '\')"><i class="fa fa-edit"></i>结束会议</a> ');
                            actions.push('<a class="btn btn-warning btn-xs apply" href="javascript:void(0)" onclick="noteMeet(\'' + row.id + '\')"><i class="fa fa-edit"></i>会议纪要</a> ');
                        }else if(row.meeting == 3){
                            actions.push('<a class="btn btn-warning btn-xs apply" href="javascript:void(0)" onclick="noteMeet(\'' + row.id + '\')"><i class="fa fa-edit"></i>会议纪要</a> ');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function openMeet(id){
            var options = {
                url: prefix + "/open/" + id,
                width: '200',
                height: '120',
                title : '开始会议'
            }
            $.modal.openOptions(options)
        }

        function endMeet(id){
            var options = {
                url: prefix + "/end/" + id,
                width: '200',
                height: '120',
                title : '结束会议'
            }
            $.modal.openOptions(options)
        }

        function noteMeet(id){
            var options = {
                url: prefix + "/note/" + id,
                width: '600',
                height: '420',
                title : '会议纪要'
            }
            $.modal.openOptions(options)
        }

        /* 用户管理-新增-选择部门树 */
        function selectDeptTree() {
            var treeId = $("#treeId").val();
            var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
            var url = ctx + "system/user/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "380",
                url: url,
                callBack: doSubmit
            };
            console.log(deptId)
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var body = $.modal.getChildFrame(index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            $.modal.close(index);
        }
    </script>
</body>
</html>